#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>
class gro
{
public:
	virtual int add(int x, int y) = 0;
	virtual int sub(int x, int y) = 0;
};
class groA :public gro
{
public:
	int add(int x, int y)
	{
		return x + y;
	}
	int sub(int x, int y)
	{
		return x - y;
	}
};
class groB :public gro
{
public:
	int add(int x, int y)
	{
		return x + y;
	}
	int sub(int x, int y)
	{
		int i = 0;
		int sum = 0;
		while (x || y)
		{
			if (x % 10 < y % 10)
			{
				sum += (x % 10 + 10 - y % 10) * pow(10, i);
			}
			else
			{
				sum += (x % 10 - y % 10) * pow(10, i);
			}
			x /= 10;
			y /= 10;
			i++;
		}
		return sum;
	}
};
class groC :public gro
{
public:
	int add(int x, int y)
	{
		int sum = 0;
		int i = 0;
		while (x || y)
		{
			if (x % 10 + y % 10 > 10)
			{
				sum += (x % 10 + y % 10 - 10) * pow(10, i);
			}
			else
			{
				sum += (x % 10 + y % 10) * pow(10, i);
			}
			x /= 10;
			y /= 10;
			i++;
		}
		return sum;

	}
	int sub(int x, int y)
	{
		int i = 0;
		int sum = 0;
		while (x || y)
		{
			if (x % 10 < y % 10)
			{
				sum += (x % 10 + 10 - y % 10) * pow(10, i);
			}
			else
			{
				sum += (x % 10 - y % 10) * pow(10, i);
			}
			x /= 10;
			y /= 10;
			i++;
		}
		return sum;
	}
};
using namespace std;
int main()
{
	int sum;
	cin >> sum;
	gro* p;
	int no;
	int x, y;
	char ch;
	while (sum--)
	{
		cin >> no >> x >> ch >> y;
		if (no == 1)
		{
			groA a1;
			p = &a1;
			if (ch == '+')
			{
				cout << p->add(x, y) << endl;
			}
			else
			{
				cout << p->sub(x, y) << endl;
			}
		}
		else if (no == 2)
		{
			groB a2;
			p = &a2;
			if (ch == '+')
			{
				cout << p->add(x, y) << endl;
			}
			else
			{
				cout << p->sub(x, y) << endl;
			}
		}
		else if (no == 3)
		{
			groC a3;
			p = &a3;
			if (ch == '+')
			{
				cout << p->add(x, y) << endl;
			}
			else
			{
				cout << p->sub(x, y) << endl;
			}

		}
	}
}